$OpenBSD: patch-bam_lua,v 1.1 2015/12/27 17:56:22 jasper Exp $

- Don't enforce stack protector
- Don't hardcode python
- Make it possible to use wavpack as an external dependency (from Debian)
- Fix zlib external dependency (from Debian)

--- bam.lua.orig	Wed May  1 13:47:39 2013
+++ bam.lua	Thu May  8 16:13:57 2014
@@ -7,12 +7,12 @@ Import("other/freetype/freetype.lua")
 --- Setup Config -------
 config = NewConfig()
 config:Add(OptCCompiler("compiler"))
-config:Add(OptTestCompileC("stackprotector", "int main(){return 0;}", "-fstack-protector -fstack-protector-all"))
 config:Add(OptTestCompileC("minmacosxsdk", "int main(){return 0;}", "-mmacosx-version-min=10.5 -isysroot /Developer/SDKs/MacOSX10.5.sdk"))
 config:Add(OptTestCompileC("macosxppc", "int main(){return 0;}", "-arch ppc"))
 config:Add(OptLibrary("zlib", "zlib.h", false))
 config:Add(SDL.OptFind("sdl", true))
 config:Add(FreeType.OptFind("freetype", true))
+config:Add(OptLibrary("wavpack", "wavpack/wavpack.h", false))
 config:Finalize("config.lua")
 
 -- data compiler
@@ -20,7 +20,7 @@ function Script(name)
 	if family == "windows" then
 		return str_replace(name, "/", "\\")
 	end
-	return "python " .. name
+	return "${MODPY_BIN} " .. name
 end
 
 function CHash(output, ...)
@@ -157,9 +157,6 @@ function build(settings)
 				settings.cc.flags:Add("-isysroot /Developer/SDKs/MacOSX10.5.sdk")
 				settings.link.flags:Add("-isysroot /Developer/SDKs/MacOSX10.5.sdk")
 			end
-		elseif config.stackprotector.value == 1 then
-			settings.cc.flags:Add("-fstack-protector", "-fstack-protector-all")
-			settings.link.flags:Add("-fstack-protector", "-fstack-protector-all")
 		end
 	end
 
@@ -187,7 +184,7 @@ function build(settings)
 	end
 
 	-- compile zlib if needed
-	if config.zlib.value == 1 then
+	if config.zlib.value then
 		settings.link.libs:Add("z")
 		if config.zlib.include_path then
 			settings.cc.includes:Add(config.zlib.include_path)
@@ -198,8 +195,20 @@ function build(settings)
 		settings.cc.includes:Add("src/engine/external/zlib")
 	end
 
+	-- compile wavpack if needed
+	if config.wavpack.value then
+		settings.link.libs:Add("wavpack")
+		if config.wavpack.include_path then
+			settings.cc.includes:Add(config.wavpack.include_path .. "/include")
+			settings.link.libpath:Add(config.wavpack.include_path .. "/lib")
+		end
+		wavpack = {}
+	else
+		wavpack = Compile(settings, Collect("src/engine/external/wavpack/*.c"))
+		settings.cc.includes:Add("src/engine/external")
+	end
+
 	-- build the small libraries
-	wavpack = Compile(settings, Collect("src/engine/external/wavpack/*.c"))
 	pnglite = Compile(settings, Collect("src/engine/external/pnglite/*.c"))
 
 	-- build game components
